//点击物品，物品高亮，向上升起一下的效果
import { Behaviour } from "../engine/Behaviour";
import { BitmapRenderer } from "../engine/BitmapRenderer";
import { Transform } from "../engine/Transform";
import { number } from "../engine/validators/number";
import { getGameObjectById } from "../engine";

export class objectLift extends Behaviour{
    
    currentSpeedY = 1;
    initialY
    nowPositionY
    flag = -2

    constructor() {
        super();
    }

    onStart() {
        //一开始先存一个初始位置
        this.initialY = this.gameObject.getBehaviour(Transform).y
    }

    onTick(duringTime: number) {
        
        //油勺升起
        if(this.flag === -1){

            const transform = this.gameObject.getBehaviour(Transform);
            if(transform.y > 90 && transform.y < 110){
                //console.log(transform.y)
                transform.y -= this.currentSpeedY;
            }        
        }
        //坐标归位
        if(this.flag === 0){
            this.gameObject.getBehaviour(Transform).y = this.initialY
            //console.log("initialY： "+ this.initialY)
        }
        
        //鸡蛋升起
        if(this.flag === 1){
            //egg的transform.y
            const transform = this.gameObject.getBehaviour(Transform);

            if(transform.y > 360 && transform.y < 400){
                //console.log(transform.y)
                transform.y -= this.currentSpeedY;
            }
        }
        //面皮升起
        if(this.flag === 2){

            const transform = this.gameObject.getBehaviour(Transform);
            if(transform.y > 280 && transform.y < 310){
                //console.log(transform.y)
                transform.y -= this.currentSpeedY;
            }        
        }
        //洋葱/香菜/酱/糖升起
        if(this.flag === 3){

            const transform = this.gameObject.getBehaviour(Transform);
            if(transform.y > 100 && transform.y < 140){
                //console.log(transform.y)
                transform.y -= this.currentSpeedY;
            }        
        }
        //香肠/辣条/培根升起
        if(this.flag === 4){

            const transform = this.gameObject.getBehaviour(Transform);
            if(transform.y > 60 && transform.y < 80){
                //console.log(transform.y)
                transform.y -= this.currentSpeedY;
            }        
        }
        //鸡肉升起
        if(this.flag === 5){

            const transform = this.gameObject.getBehaviour(Transform);
            if(transform.y > 190 && transform.y < 210){
                //console.log(transform.y)
                transform.y -= this.currentSpeedY;
            }        
        }
        //蒜蓉/葱花/辣酱升起
        if(this.flag === 6){

            const transform = this.gameObject.getBehaviour(Transform);
            if(transform.y > 60 && transform.y < 80){
                //console.log(transform.y)
                transform.y -= this.currentSpeedY;
            }        
        }
        //辣酱升起
        if(this.flag === 7){

            const transform = this.gameObject.getBehaviour(Transform);
            if(transform.y > 40 && transform.y < 60){
                //console.log(transform.y)
                transform.y -= this.currentSpeedY;
            }        
        }
        
    }

        

}
